]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dash: Improve feedback when favorite-apps key is locked
authorDavid King <amigadave@amigadave.com>
Thu, 11 Dec 2014 15:22:19 +0000 (15:22 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Wed, 28 Jan 2015 13:15:51 +0000 (14:15 +0100)
In a lockdown scenario, where the favorite-apps GSettings key is not
writable, hide the menu items for adding and removing favorites from the
dash menu. Additionally, reject drops to the dash for DND.

https://bugzilla.gnome.org/show_bug.cgi?id=741325

js/ui/appDisplay.js
js/ui/dash.js

index 5a14aca9ef3586c387ed815a33031b3297af84a4..4ecc7ec8cdbef8f5332ee6b5b669f578386990cc 100644 (file)
@@ -1748,6 +1748,8 @@ const AppIconMenu = new Lang.Class({
 
         this.actor.add_style_class_name('app-well-menu');
 
+        this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
+
         // Chain our visibility and lifecycle to that of the source
         source.actor.connect('notify::mapped', Lang.bind(this, function () {
             if (!source.actor.mapped)
@@ -1807,22 +1809,27 @@ const AppIconMenu = new Lang.Class({
                     this.emit('activate-window', null);
                 }));
             }
-            this._appendSeparator();
 
-            let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._source.app.get_id());
+            let canFavorite = this._settings.is_writable('favorite-apps');
 
-            if (isFavorite) {
-                let item = this._appendMenuItem(_("Remove from Favorites"));
-                item.connect('activate', Lang.bind(this, function() {
-                    let favs = AppFavorites.getAppFavorites();
-                    favs.removeFavorite(this._source.app.get_id());
-                }));
-            } else {
-                let item = this._appendMenuItem(_("Add to Favorites"));
-                item.connect('activate', Lang.bind(this, function() {
-                    let favs = AppFavorites.getAppFavorites();
-                    favs.addFavorite(this._source.app.get_id());
-                }));
+            if (canFavorite) {
+                this._appendSeparator();
+
+                let isFavorite = AppFavorites.getAppFavorites().isFavorite(this._source.app.get_id());
+
+                if (isFavorite) {
+                    let item = this._appendMenuItem(_("Remove from Favorites"));
+                    item.connect('activate', Lang.bind(this, function() {
+                        let favs = AppFavorites.getAppFavorites();
+                        favs.removeFavorite(this._source.app.get_id());
+                    }));
+                } else {
+                    let item = this._appendMenuItem(_("Add to Favorites"));
+                    item.connect('activate', Lang.bind(this, function() {
+                        let favs = AppFavorites.getAppFavorites();
+                        favs.addFavorite(this._source.app.get_id());
+                    }));
+                }
             }
 
             if (Shell.AppSystem.get_default().lookup_app('org.gnome.Software.desktop')) {
index 99635cd445579b66f8352883af4e47bf66fdbcd0..acf1eb40b0800f6c2ea307abfd56c3d416d6d392 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Signals = imports.signals;
 const Lang = imports.lang;
@@ -269,6 +270,9 @@ const ShowAppsIcon = new Lang.Class({
         if (app == null)
             return false;
 
+        if (!this._settings.is_writable('favorite-apps'))
+            return false;
+
         let id = app.get_id();
         let isFavorite = AppFavorites.getAppFavorites().isFavorite(id);
         return isFavorite;
@@ -424,6 +428,8 @@ const Dash = new Lang.Class({
 
         this._workId = Main.initializeDeferredWork(this._box, Lang.bind(this, this._redisplay));
 
+        this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
+
         this._appSystem = Shell.AppSystem.get_default();
 
         this._appSystem.connect('installed-changed', Lang.bind(this, function() {
@@ -850,6 +856,9 @@ const Dash = new Lang.Class({
         if (app == null || app.is_window_backed())
             return DND.DragMotionResult.NO_DROP;
 
+        if (!this._settings.is_writable('favorite-apps'))
+            return DND.DragMotionResult.NO_DROP;
+
         let favorites = AppFavorites.getAppFavorites().getFavorites();
         let numFavorites = favorites.length;
 
@@ -926,6 +935,9 @@ const Dash = new Lang.Class({
             return false;
         }
 
+        if (!this._settings.is_writable('favorite-apps'))
+            return false;
+
         let id = app.get_id();
 
         let favorites = AppFavorites.getAppFavorites().getFavoriteMap();